package com.omni.dao.clause;

public class OrderClause {

	private final StringBuffer statments;
	private boolean isFirstLine = true;

	private OrderClause() {

		statments = new StringBuffer();
	}

	public static OrderClause create() {

		return new OrderClause();
	}

	public OrderClause ascending(String field) {

		if (isFirstLine) {
			statments.append(String.format(" %s ASC ", field));
			isFirstLine = false;
		} else {
			statments.append(String.format(" ,%s ASC ", field));
		}

		return this;
	}

	public OrderClause descending(String field) {

		if (isFirstLine) {
			statments.append(String.format(" %s DESC ", field));
			isFirstLine = false;
		} else {
			statments.append(String.format(" ,%s DESC ", field));
		}

		return this;
	}

	@Override
	public String toString() {
		return statments.toString();
	}
}
